package GUIadapter;

import java.util.List;

import javax.swing.table.AbstractTableModel;

import ModelLayer.SaleItem;

@SuppressWarnings("serial")
public class SaleItemModel extends AbstractTableModel
{
	private final String[] columnHeader = {	"Varenummer",
											"Beskrivelse",
											"Pris",
											"Antal",
											"Lokation",
											"Stregkode",
											"Min antal vare",
											"Maks antal vare"
											};

	private List<SaleItem> saleItemList;

	public SaleItemModel(List<SaleItem> saleItemList)
	{
		this.saleItemList = saleItemList;
	}

	@Override
	public String getColumnName(int column)
	{
		// TODO Auto-generated method stub
		return columnHeader[column];
	}

	@Override
	public int getColumnCount()
	{
		// TODO Auto-generated method stub
		return columnHeader.length;
	}

	@Override
	public int getRowCount()
	{
		// TODO Auto-generated method stub
		return saleItemList.size();
	}

	@Override
	public Object getValueAt(int row, int col)
	{
		// TODO Auto-generated method stub
		SaleItem saleItem = saleItemList.get(row);
		switch(col)
		{
		case 0:
			return new Integer(saleItem.getItemnr());
		case 1:
			return saleItem.getDescription();
		case 2:
			return saleItem.getPrice();
		case 3:
			return saleItem.getInStock();
		case 4:
			return saleItem.getLocation();
		case 5:
			return saleItem.getBarCode();
		case 6:
			return saleItem.getMinAmount();
		case 7:
			return saleItem.getMaxAmount();
		}
		return null;
	}

}

